export interface Refs {
    theGrid: YvanUI.CtlGrid;
}

export default abstract class View<M,INP> extends YvanUI.BaseModule<M, Refs, INP> {

    query = {
        login_name: '',
    };

    viewResolver(): any {
        return {
            rows: [
                {
                    cols: [
                        {
                            width: "300",
                            view: "text",
                            label: "登录名",
                            changeValueImplete: true,
                            entityName: "query.login_name",
                        },
                        {
                            view: "button",
                            text: "查询",
                            icon: "fa fa-bars",
                            onClick: {
                                type: "function",
                                bind: "click1",
                            },
                        },
                        {}
                    ]
                },
                {
                    view: "grid",
                    ctlName: "theGrid",
                    idField: "user_id",
                    pagination: true,
                    pageSize: 20,
                    columns: [
                        {
                            field: "user_id",
                            hidden: true
                        },
                        {
                            title: "操作",
                            width: 100,
                            buttons: [
                                {
                                    text: "详情",
                                    onClick: {
                                        type: "function",
                                        bind: "gridRowDetail"
                                    },
                                },
                                {
                                    text: "删除",
                                    cssType: "danger",
                                    onClick: {
                                        type: "function",
                                        bind: "gridDelete"
                                    },
                                },
                            ],
                        },
                        {
                            field: "login_name",
                            title: "登录名",
                            width: 100,
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "staff_name",
                            title: "职员姓名",
                            width: 100,
                            filterable: true,
                        },
                        {
                            field: "gender",
                            title: "性别",
                            width: 70,
                            formatter: [
                                { id: "M", text: "男" },
                                { id: "F", text: "女" },
                            ],
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "duty",
                            title: "职务",
                            width: 100,
                            filterable: true,
                        },
                        {
                            field: "mobile",
                            title: "手机",
                            width: 120,
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "ui_style",
                            title: "界面风格",
                            width: 100,
                            formatter: [
                                { id: "light", text: "浅色风格" },
                                { id: "dark", text: "暗色风格" },
                            ],
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "login_count",
                            title: "登录次数",
                            width: 90,
                            align: "right",
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "last_login_time",
                            title: "最后登录时间",
                            width: 160,
                            formatter: "fmtDate",
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "user_state",
                            title: "是否锁定",
                            width: 100,
                            formatter: [
                                { id: "0", text: "锁定" },
                                { id: "1", text: "正常" },
                            ],
                            onStyle({ value: e }) {
                                if (e == "1") {
                                    return { color: 'green' }
                                }
                                return { color: 'red' }
                            },
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "birthday",
                            title: "生日",
                            width: 100,
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "create_at",
                            title: "创建时间",
                            width: 160,
                            formatter: "fmtDate",
                            filterable: true,
                            sortable: true,
                        },
                        {
                            field: "update_at",
                            title: "最后更新时间",
                            width: 160,
                            formatter: "fmtDate",
                            filterable: true,
                            sortable: true,
                        },
                    ],
                    dataSource: {
                        type: "Server",
                        method: "/grid/GridService@selectAll",
                        params: {
                            login_name: {$get: 'query.login_name'},
                        }
                    }
                },
            ],
        };
    }
}
